<?php
class Calendar extends AppModel {
	var $name = 'Calendar';
	
	var $hasAndBelongsToMany = array('Tag');
	
		var $belongsTo = array(
			'Organization' =>
				array('className' => 'Organization'
				),
		);
		var $hasMany = array(
			'Event' =>array('classname'  => 'Event'),
		);
	
	function findEvents($url=array()) {
		//$this->bindModel(array('hasMany'=>array('Event')));
		//return $this->Event->findAll("YEAR(date)=".$year." AND MONTH(date)=".$month);
		
		if ($url['calendar'] != 'all') {
			$calendars = $this->findAll(array('Calendar.shortname'=>$url['calendar']),null,'Calendar.shortname ASC',null,null,2);
		} else {
			$calendars = $this->findAll(null,null,'Calendar.shortname ASC',null,null,2);
		}
		
		return $calendars;
	}
} 
